//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
// MicrosoftMvcAjax.js

Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_AjaxOptions=function(){return {};}
Sys.Mvc.InsertionMode=function(){};Sys.Mvc.InsertionMode.prototype = {replace:0,insertBefore:1,insertAfter:2}
Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode',false);Sys.Mvc.$create_JsonValidationField=function(){return {};}
Sys.Mvc.$create_JsonValidationOptions=function(){return {};}
Sys.Mvc.$create_JsonValidationRule=function(){return {};}
Sys.Mvc.AjaxContext=function(request,updateTarget,loadingElement,insertionMode){this.$3=request;this.$4=updateTarget;this.$1=loadingElement;this.$0=insertionMode;}
Sys.Mvc.AjaxContext.prototype={$0:0,$1:null,$2:null,$3:null,$4:null,get_data:function(){if(this.$2){return this.$2.get_responseData();}else{return null;}},get_insertionMode:function(){return this.$0;},get_loadingElement:function(){return this.$1;},get_object:function(){var $0=this.get_response();return ($0)?$0.get_object():null;},get_response:function(){return this.$2;},set_response:function(value){this.$2=value;return value;},get_request:function(){return this.$3;},get_updateTarget:function(){return this.$4;}}
Sys.Mvc.AsyncHyperlink=function(){}
Sys.Mvc.AsyncHyperlink.handleClick=function(anchor,evt,ajaxOptions){evt.preventDefault();Sys.Mvc.MvcHelpers.$2(anchor.href,'post','',anchor,ajaxOptions);}
Sys.Mvc.FieldValidation=function(formValidation,fieldElements,validationMessageElement,replaceValidationMessageContents){this.$A=[];this.$F=[];this.$C=formValidation;this.$B=fieldElements;this.$E=validationMessageElement;this.$D=replaceValidationMessageContents;this.$6=Function.createDelegate(this,this.$13);this.$7=Function.createDelegate(this,this.$14);this.$8=Function.createDelegate(this,this.$12);this.$9=Function.createDelegate(this,this.$15);}
Sys.Mvc.FieldValidation.prototype={$6:null,$7:null,$8:null,$9:null,$B:null,$C:null,$D:false,$E:null,addError:function(message){this.addErrors([message]);},addErrors:function(messages){if(!Sys.Mvc._ValidationUtil.$0(messages)){Array.addRange(this.$A,messages);this.$17();}},addValidator:function(validator){Array.add(this.$F,validator);},disableDynamicValidation:function(){for(var $0=0;$0<this.$B.length;$0++){var $1=this.$B[$0];if(Sys.Mvc._ValidationUtil.$2($1,'onpropertychange')){Sys.UI.DomEvent.removeHandler($1,'propertychange',this.$9);}else{Sys.UI.DomEvent.removeHandler($1,'input',this.$8);}Sys.UI.DomEvent.removeHandler($1,'change',this.$7);Sys.UI.DomEvent.removeHandler($1,'blur',this.$6);}},$10:function(){if(this.$E){if(this.$D){Sys.Mvc._ValidationUtil.$4(this.$E,this.$A[0]);}Sys.UI.DomElement.removeCssClass(this.$E,'field-validation-valid');Sys.UI.DomElement.addCssClass(this.$E,'field-validation-error');}for(var $0=0;$0<this.$B.length;$0++){var $1=this.$B[$0];Sys.UI.DomElement.removeCssClass($1,'input-validation-valid');Sys.UI.DomElement.addCssClass($1,'input-validation-error');}},$11:function(){if(this.$E){if(this.$D){Sys.Mvc._ValidationUtil.$4(this.$E,'');}Sys.UI.DomElement.removeCssClass(this.$E,'field-validation-error');Sys.UI.DomElement.addCssClass(this.$E,'field-validation-valid');}for(var $0=0;$0<this.$B.length;$0++){var $1=this.$B[$0];Sys.UI.DomElement.removeCssClass($1,'input-validation-error');Sys.UI.DomElement.addCssClass($1,'input-validation-valid');}},$12:function($p0){$p0.target['__MVC_HasTextChanged'] = true;if($p0.target['__MVC_HasValidationFired']){this.validate();}},$13:function($p0){if($p0.target['__MVC_HasTextChanged']||$p0.target['__MVC_HasValidationFired']){this.validate();}},$14:function($p0){$p0.target['__MVC_HasTextChanged'] = true;},$15:function($p0){if($p0.rawEvent.propertyName==='value'){$p0.target['__MVC_HasTextChanged'] = true;if($p0.target['__MVC_HasValidationFired']){this.validate();}}},enableDynamicValidation:function(){for(var $0=0;$0<this.$B.length;$0++){var $1=this.$B[$0];if(Sys.Mvc._ValidationUtil.$2($1,'onpropertychange')){Sys.UI.DomEvent.addHandler($1,'propertychange',this.$9);}else{Sys.UI.DomEvent.addHandler($1,'input',this.$8);}Sys.UI.DomEvent.addHandler($1,'change',this.$7);Sys.UI.DomEvent.addHandler($1,'blur',this.$6);}},$16:function(){return (this.$B.length>0)?this.$B[0].value:null;},$17:function(){if(!this.$A.length){this.$11();}else{this.$10();}},removeAllErrors:function(){Array.clear(this.$A);this.$17();},validate:function(){var $0=[];for(var $1=0;$1<this.$F.length;$1++){var $2=this.$F[$1];var $3=$2.validate(this,this.$B,this.$16());if($3){Array.addRange($0,$3);}}for(var $4=0;$4<this.$B.length;$4++){var $5=this.$B[$4];$5['__MVC_HasValidationFired'] = true;}this.removeAllErrors();this.addErrors($0);return $0;}}
Sys.Mvc.FormValidation=function(formElement,validationSummaryElement){this.$4=[];this.$5=[];this.$6=formElement;this.$7=validationSummaryElement;formElement['__MVC_FormValidation'] = this;if(validationSummaryElement){var $0=validationSummaryElement.getElementsByTagName('ul');if($0.length>0){this.$8=$0[0];}}this.$3=Function.createDelegate(this,this.$B);}
Sys.Mvc.FormValidation.enableClientValidation=function(options,userState){Sys.Application.add_load(Function.createDelegate(null,function($p1_0,$p1_1){
Sys.Mvc.FormValidation.parseJsonOptions(options);}));}
Sys.Mvc.FormValidation.$C=function($p0,$p1){var $0=[];var $1=document.getElementsByName($p1);for(var $2=0;$2<$1.length;$2++){var $3=$1[$2];if(Sys.Mvc.FormValidation.$D($p0,$3)){Array.add($0,$3);}}return $0;}
Sys.Mvc.FormValidation.getValidationForForm=function(formElement){return formElement['__MVC_FormValidation'];}
Sys.Mvc.FormValidation.$D=function($p0,$p1){while($p1){if($p0===$p1){return true;}$p1=$p1.parentNode;}return false;}
Sys.Mvc.FormValidation.parseJsonOptions=function(options){var $0=$get(options.FormId);var $1=(!Sys.Mvc._ValidationUtil.$1(options.ValidationSummaryId))?$get(options.ValidationSummaryId):null;var $2=new Sys.Mvc.FormValidation($0,$1);$2.enableDynamicValidation();for(var $3=0;$3<options.Fields.length;$3++){var $4=options.Fields[$3];var $5=Sys.Mvc.FormValidation.$C($0,$4.FieldName);var $6=(!Sys.Mvc._ValidationUtil.$1($4.ValidationMessageId))?$get($4.ValidationMessageId):null;var $7=new Sys.Mvc.FieldValidation($2,$5,$6,$4.ReplaceValidationMessageContents);for(var $8=0;$8<$4.ValidationRules.length;$8++){var $9=$4.ValidationRules[$8];var $A=Sys.Mvc.ValidatorRegistry.getValidator($9);if($A){$7.addValidator($A);}}$7.enableDynamicValidation();$2.addFieldValidation($7);}return $2;}
Sys.Mvc.FormValidation.prototype={$3:null,$6:null,$7:null,$8:null,addError:function(message){this.addErrors([message]);},addErrors:function(messages){if(!Sys.Mvc._ValidationUtil.$0(messages)){Array.addRange(this.$4,messages);this.$E();}},addFieldValidation:function(validation){Array.add(this.$5,validation);},disableDynamicValidation:function(){Sys.UI.DomEvent.removeHandler(this.$6,'submit',this.$3);},$9:function(){if(this.$7){if(this.$8){Sys.Mvc._ValidationUtil.$3(this.$8);for(var $0=0;$0<this.$4.length;$0++){var $1=document.createElement('li');Sys.Mvc._ValidationUtil.$4($1,this.$4[$0]);this.$8.appendChild($1);}}Sys.UI.DomElement.removeCssClass(this.$7,'validation-summary-valid');Sys.UI.DomElement.addCssClass(this.$7,'validation-summary-errors');}},$A:function(){if(this.$7){if(this.$8){this.$8.innerHTML='';}Sys.UI.DomElement.removeCssClass(this.$7,'validation-summary-errors');Sys.UI.DomElement.addCssClass(this.$7,'validation-summary-valid');}},enableDynamicValidation:function(){Sys.UI.DomEvent.addHandler(this.$6,'submit',this.$3);},$B:function($p0){var $0=$p0.target;var $1=this.validate(true);if(!Sys.Mvc._ValidationUtil.$0($1)){$p0.preventDefault();}},$E:function(){if(!this.$4.length){this.$A();}else{this.$9();}},removeAllErrors:function(){Array.clear(this.$4);this.$E();},validate:function(replaceValidationSummary){var $0=[];for(var $1=0;$1<this.$5.length;$1++){var $2=this.$5[$1];var $3=$2.validate();if($3){Array.addRange($0,$3);}}if(replaceValidationSummary){this.removeAllErrors();this.addErrors($0);}return $0;}}
Sys.Mvc.MvcHelpers=function(){}
Sys.Mvc.MvcHelpers.$0=function($p0,$p1,$p2){if($p0.disabled){return null;}var $0=$p0.name;if($0){var $1=$p0.tagName.toUpperCase();var $2=encodeURIComponent($0);var $3=$p0;if($1==='INPUT'){var $4=$3.type;if($4==='submit'){return $2+'='+encodeURIComponent($3.value);}else if($4==='image'){return $2+'.x='+$p1+'&'+$2+'.y='+$p2;}}else if(($1==='BUTTON')&&($0.length)&&($3.type==='submit')){return $2+'='+encodeURIComponent($3.value);}}return null;}
Sys.Mvc.MvcHelpers.$1=function($p0){var $0=$p0.elements;var $1=new Sys.StringBuilder();var $2=$0.length;for(var $4=0;$4<$2;$4++){var $5=$0[$4];var $6=$5.name;if(!$6||!$6.length){continue;}var $7=$5.tagName.toUpperCase();if($7==='INPUT'){var $8=$5;var $9=$8.type;if(($9==='text')||($9==='password')||($9==='hidden')||((($9==='checkbox')||($9==='radio'))&&$5.checked)){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($8.value));$1.append('&');}}else if($7==='SELECT'){var $A=$5;var $B=$A.options.length;for(var $C=0;$C<$B;$C++){var $D=$A.options[$C];if($D.selected){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($D.value));$1.append('&');}}}else if($7==='TEXTAREA'){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent(($5.value)));$1.append('&');}}var $3=$p0._additionalInput;if($3){$1.append($3);$1.append('&');}return $1.toString();}
Sys.Mvc.MvcHelpers.$2=function($p0,$p1,$p2,$p3,$p4){if($p4.confirm){if(!confirm($p4.confirm)){return;}}if($p4.url){$p0=$p4.url;}if($p4.httpMethod){$p1=$p4.httpMethod;}if($p2.length>0&&!$p2.endsWith('&')){$p2+='&';}$p2+='X-Requested-With=XMLHttpRequest';var $0=$p1.toUpperCase();var $1=($0==='GET'||$0==='POST');if(!$1){$p2+='&';$p2+='X-HTTP-Method-Override='+$0;}var $2='';if($0==='GET'||$0==='DELETE'){if($p0.indexOf('?')>-1){if(!$p0.endsWith('&')){$p0+='&';}$p0+=$p2;}else{$p0+='?';$p0+=$p2;}}else{$2=$p2;}var $3=new Sys.Net.WebRequest();$3.set_url($p0);if($1){$3.set_httpVerb($p1);}else{$3.set_httpVerb('POST');$3.get_headers()['X-HTTP-Method-Override']=$0;}$3.set_body($2);if($p1.toUpperCase()==='PUT'){$3.get_headers()['Content-Type']='application/x-www-form-urlencoded;';}$3.get_headers()['X-Requested-With']='XMLHttpRequest';var $4=null;if($p4.updateTargetId){$4=$get($p4.updateTargetId);}var $5=null;if($p4.loadingElementId){$5=$get($p4.loadingElementId);}var $6=new Sys.Mvc.AjaxContext($3,$4,$5,$p4.insertionMode);var $7=true;if($p4.onBegin){$7=$p4.onBegin($6)!==false;}if($5){Sys.UI.DomElement.setVisible($6.get_loadingElement(),true);}if($7){$3.add_completed(Function.createDelegate(null,function($p1_0){
Sys.Mvc.MvcHelpers.$3($3,$p4,$6);}));$3.invoke();}}
Sys.Mvc.MvcHelpers.$3=function($p0,$p1,$p2){$p2.set_response($p0.get_executor());if($p1.onComplete&&$p1.onComplete($p2)===false){return;}var $0=$p2.get_response().get_statusCode();if(($0>=200&&$0<300)||$0===304||$0===1223){if($0!==204&&$0!==304&&$0!==1223){var $1=$p2.get_response().getResponseHeader('Content-Type');if(($1)&&($1.indexOf('application/x-javascript')!==-1)){eval($p2.get_data());}else{Sys.Mvc.MvcHelpers.updateDomElement($p2.get_updateTarget(),$p2.get_insertionMode(),$p2.get_data());}}if($p1.onSuccess){$p1.onSuccess($p2);}}else{if($p1.onFailure){$p1.onFailure($p2);}}if($p2.get_loadingElement()){Sys.UI.DomElement.setVisible($p2.get_loadingElement(),false);}}
Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:target.innerHTML=content;break;case 1:if(content&&content.length>0){target.innerHTML=content+target.innerHTML.trimStart();}break;case 2:if(content&&content.length>0){target.innerHTML=target.innerHTML.trimEnd()+content;}break;}}}
Sys.Mvc.AsyncForm=function(){}
Sys.Mvc.AsyncForm.handleClick=function(form,evt){var $0=Sys.Mvc.MvcHelpers.$0(evt.target,evt.offsetX,evt.offsetY);form._additionalInput = $0;}
Sys.Mvc.AsyncForm.handleSubmit=function(form,evt,ajaxOptions){evt.preventDefault();var $0=Sys.Mvc.MvcHelpers.$1(form);Sys.Mvc.MvcHelpers.$2(form.action,form.method||'post',$0,form,ajaxOptions);}
Sys.Mvc.RangeValidator=function(errorMessage,minimum,maximum){Sys.Mvc.RangeValidator.initializeBase(this);this.$0=errorMessage;this.$1=minimum;this.$2=maximum;}
Sys.Mvc.RangeValidator.$3=function($p0){var $0=$p0.ValidationParameters['minimum'];var $1=$p0.ValidationParameters['maximum'];return new Sys.Mvc.RangeValidator($p0.ErrorMessage,$0,$1);}
Sys.Mvc.RangeValidator.prototype={$0:null,$1:null,$2:null,validate:function(validation,elements,value){if(Sys.Mvc._ValidationUtil.$1(value)){return null;}var $0=Number.parseLocale(value);return (isNaN($0)||$0<this.$1||$0>this.$2)?[this.$0]:null;}}
Sys.Mvc.RegularExpressionValidator=function(errorMessage,pattern){Sys.Mvc.RegularExpressionValidator.initializeBase(this);this.$0=errorMessage;this.$1=pattern;}
Sys.Mvc.RegularExpressionValidator.$2=function($p0){var $0=$p0.ValidationParameters['pattern'];return new Sys.Mvc.RegularExpressionValidator($p0.ErrorMessage,$0);}
Sys.Mvc.RegularExpressionValidator.prototype={$0:null,$1:null,validate:function(validation,elements,value){if(Sys.Mvc._ValidationUtil.$1(value)){return null;}var $0=new RegExp(this.$1);var $1=$0.exec(value);return (!Sys.Mvc._ValidationUtil.$0($1)&&$1[0].length===value.length)?null:[this.$0];}}
Sys.Mvc.RequiredValidator=function(errorMessage){Sys.Mvc.RequiredValidator.initializeBase(this);this.$0=errorMessage;}
Sys.Mvc.RequiredValidator.$1=function($p0){return new Sys.Mvc.RequiredValidator($p0.ErrorMessage);}
Sys.Mvc.RequiredValidator.$2=function($p0){if($p0.tagName.toUpperCase()==='INPUT'){var $0=($p0.type).toUpperCase();if($0==='RADIO'){return true;}}return false;}
Sys.Mvc.RequiredValidator.$3=function($p0){if($p0.tagName.toUpperCase()==='SELECT'){return true;}return false;}
Sys.Mvc.RequiredValidator.$4=function($p0){if($p0.tagName.toUpperCase()==='INPUT'){var $0=($p0.type).toUpperCase();switch($0){case 'TEXT':case 'PASSWORD':case 'FILE':return true;}}if($p0.tagName.toUpperCase()==='TEXTAREA'){return true;}return false;}
Sys.Mvc.RequiredValidator.prototype={$0:null,validate:function(validation,elements,value){if(!elements.length){return null;}var $0=elements[0];if(Sys.Mvc.RequiredValidator.$4($0)){return this.$7($0);}if(Sys.Mvc.RequiredValidator.$2($0)){return this.$5(elements);}if(Sys.Mvc.RequiredValidator.$3($0)){return this.$6(($0).options);}return null;},$5:function($p0){for(var $0=0;$0<$p0.length;$0++){var $1=$p0[$0];if($1.checked){return null;}}return [this.$0];},$6:function($p0){for(var $0=0;$0<$p0.length;$0++){var $1=$p0[$0];if($1.selected){if(!Sys.Mvc._ValidationUtil.$1($1.value)){return null;}}}return [this.$0];},$7:function($p0){return (Sys.Mvc._ValidationUtil.$1($p0.value))?[this.$0]:null;}}
Sys.Mvc.StringLengthValidator=function(errorMessage,minLength,maxLength){Sys.Mvc.StringLengthValidator.initializeBase(this);this.$0=errorMessage;this.$2=minLength;this.$1=maxLength;}
Sys.Mvc.StringLengthValidator.$3=function($p0){var $0=$p0.ValidationParameters['minimumLength'];var $1=$p0.ValidationParameters['maximumLength'];return new Sys.Mvc.StringLengthValidator($p0.ErrorMessage,$0,$1);}
Sys.Mvc.StringLengthValidator.prototype={$0:null,$1:0,$2:0,validate:function(validation,elements,value){if(Sys.Mvc._ValidationUtil.$1(value)){return null;}return (this.$2<=value.length&&value.length<=this.$1)?null:[this.$0];}}
Sys.Mvc._ValidationUtil=function(){}
Sys.Mvc._ValidationUtil.$0=function($p0){return (!$p0||!$p0.length);}
Sys.Mvc._ValidationUtil.$1=function($p0){return (!$p0||!$p0.length);}
Sys.Mvc._ValidationUtil.$2=function($p0,$p1){return ($p1 in $p0);}
Sys.Mvc._ValidationUtil.$3=function($p0){while($p0.firstChild){$p0.removeChild($p0.firstChild);}}
Sys.Mvc._ValidationUtil.$4=function($p0,$p1){var $0=document.createTextNode($p1);Sys.Mvc._ValidationUtil.$3($p0);$p0.appendChild($0);}
Sys.Mvc.Validator=function(){}
Sys.Mvc.ValidatorRegistry=function(){}
Sys.Mvc.ValidatorRegistry.get_creators=function(){return Sys.Mvc.ValidatorRegistry.$0;}
Sys.Mvc.ValidatorRegistry.getValidator=function(rule){var $0=Sys.Mvc.ValidatorRegistry.$0[rule.ValidationType];return ($0)?$0(rule):null;}
Sys.Mvc.ValidatorRegistry.$1=function(){return {required:Function.createDelegate(null,Sys.Mvc.RequiredValidator.$1),stringLength:Function.createDelegate(null,Sys.Mvc.StringLengthValidator.$3),regularExpression:Function.createDelegate(null,Sys.Mvc.RegularExpressionValidator.$2),range:Function.createDelegate(null,Sys.Mvc.RangeValidator.$3)};}
Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext');Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink');Sys.Mvc.FieldValidation.registerClass('Sys.Mvc.FieldValidation');Sys.Mvc.FormValidation.registerClass('Sys.Mvc.FormValidation');Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers');Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm');Sys.Mvc.Validator.registerClass('Sys.Mvc.Validator');Sys.Mvc.RangeValidator.registerClass('Sys.Mvc.RangeValidator',Sys.Mvc.Validator);Sys.Mvc.RegularExpressionValidator.registerClass('Sys.Mvc.RegularExpressionValidator',Sys.Mvc.Validator);Sys.Mvc.RequiredValidator.registerClass('Sys.Mvc.RequiredValidator',Sys.Mvc.Validator);Sys.Mvc.StringLengthValidator.registerClass('Sys.Mvc.StringLengthValidator',Sys.Mvc.Validator);Sys.Mvc._ValidationUtil.registerClass('Sys.Mvc._ValidationUtil');Sys.Mvc.ValidatorRegistry.registerClass('Sys.Mvc.ValidatorRegistry');Sys.Mvc.ValidatorRegistry.$0=Sys.Mvc.ValidatorRegistry.$1();
// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
// -----------------------------------
